﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TypeTreeConfig.aspx.cs" Inherits="ZLCMS.Web.SystemManage.Basics.TypeTreeConfig" %>



<div class="pageContent">   
   	<div class="panelBar">
		<ul class="toolBar">           
            <li><a class="icon" href="javascript:void(0)" onclick="navTab.reload();" title="刷新分类"><span>刷新分类</span></a></li>
 		</ul>
	</div>

    <div class="unitBox" style="float:left; display:block; overflow:auto; width:358px;">
<div class="pageHeader" style="border:1px #B8D0D6 solid">
	<div class="searchBar">
		<table class="searchContent" width="100%">
			<tr>
				<td width="300px"><h3>分类</h3>
				</td>
			</tr>
		</table>
	</div>
</div>
		
        
<div class="pageContent" style="border:1px #B8D0D6 solid;"  layoutH="70">

<div class="pageFormContent" layoutH="128">
<ul class="ztree" id="adminmenu_tree" setting='
{
	view: {
		addHoverDom: addHoverDom,
		removeHoverDom: removeHoverDom,
		selectedMulti: false
	},
    data: {
		key: {
			name: "Name"
		},
		simpleData: {
			enable: true,
			idKey: "Id",
			pIdKey: "Parent"
		},
		keep: {
			parent: false,
			leaf: false
		}
	},
	async: {
		enable: true,
		type: "post",
		url: "/SystemManage/Basics/TypeTree/TypeTreeConfigInterface.aspx?opt=load_data&kind=<%= Request["kind"] %>",
        otherParam: ["temp", new Date().valueOf()]
	},
    edit: {
		enable: true,
		editNameSelectAll: false,
		showRemoveBtn: true,
		showRenameBtn: true,
		removeTitle: "删除",
		renameTitle: "修改"
	},
	callback: {
		beforeDrag: function (treeId, treeNodes) {
			return false;
		},
        onAsyncSuccess:function(event, treeId, treeNode, msg){
            $.fn.zTree.getZTreeObj(treeId).expandAll(true);
        },
        beforeRename: function(treeId, treeNode, newName, isCancel){
            
            $.get("/SystemManage/Basics/TypeTree/TypeTreeConfigInterface.aspx", {opt:"update", kind:"<%= Request["kind"] %>", Title:newName, Preid:treeNode.Parent, Id:treeNode.Id, temp:new Date().valueOf()}, function(data){
                var obj=$.parseJSON(data);
                treeNode.ItemText = obj.ItemText;
                $.fn.zTree.getZTreeObj(treeId).updateNode(treeNode);
                alertMsg.correct("操作成功");
            });
            return true;
        },
        beforeRemove:function(treeId, treeNode){
            alertMsg.confirm("请确认删除当前菜单项", {
                okCall: function() {
                    $.get("/SystemManage/Basics/TypeTree/TypeTreeConfigInterface.aspx", {opt:"remove", kind:"<%= Request["kind"] %>", Id:treeNode.Id, temp:new Date().valueOf()}, function(data){
                        $.fn.zTree.getZTreeObj(treeId).removeChildNodes(treeNode);
                        $.fn.zTree.getZTreeObj(treeId).removeNode(treeNode);
                        alertMsg.correct("操作成功");
                    }); 
                }
            });
            return false;
        },
        onClick:function(event, treeId, treeNode, clickFlag){
            $("#Id",navTab.getCurrentPanel()).val(treeNode.Id);
            $("#ip_preid",navTab.getCurrentPanel()).val(treeNode.Parent);
            $("#Sort",navTab.getCurrentPanel()).val(treeNode.ShowOrder);
            $("#ip_p1",navTab.getCurrentPanel()).val(treeNode.Value);
            $("#ip_title",navTab.getCurrentPanel()).val(treeNode.Name);
            _currentNode = treeNode;
        }
	}
}
'/>
</div>
<div class="formBar">
	    <ul>
			<li>
            </li>
		</ul>
</div>
<script type="text/javascript">
    var _currentNode = {};
    
    function addItem(treeId, parentNode) {
        var pid = 0;
        if (parentNode) {
            pid = parentNode.Id;
        }
        $.get("/SystemManage/Basics/TypeTree/TypeTreeConfigInterface.aspx", {Kind:"<%= Request["kind"] %>", opt: "add", Title: "新的菜单", Preid: pid, temp: new Date().valueOf() }, function (data) {
            var zTree = $.fn.zTree.getZTreeObj(treeId);
            if (parentNode) {
                zTree.addNodes(parentNode, $.parseJSON(data));
            } else {
                zTree.addNodes(null, $.parseJSON(data));
            }
        });
    }

    function addHoverDom(treeId, treeNode) {
        var sObj = $("#" + treeNode.tId + "_span");
        if (treeNode.editNameFlag || $("#addBtn_" + treeNode.tId).length > 0) return;
        var addStr = "<span class='button add' id='addBtn_" + treeNode.tId
				+ "' title='增加子目录' onfocus='this.blur();'></span>";
        sObj.after(addStr);
        var btn = $("#addBtn_" + treeNode.tId);
        if (btn) btn.bind("click", function () {
            addItem(treeId, treeNode);
            return false;
        });
    };
    function removeHoverDom(treeId, treeNode) {
        $("#addBtn_" + treeNode.tId).unbind().remove();
    };
     function jieshao(){
     var kindid=$("#Id", navTab.getCurrentPanel()).val();
     if(kindid==null||kindid==""||kindid==undefined)
     {
        alert("请先选择您要查看的分类！");
      } 
      else
      {
         navTab.openTab("TypeTreeIntrodues", "/SystemManage/Basics/TypeTree/TypeTreeIntrodues.aspx?tid="+kindid+"", { title:"分类介绍", fresh:true, data:{} });
      }
    };

</script>

 
</div>
	</div>
	









    <a href="TypeTreeIntrodues.aspx">TypeTreeIntrodues.aspx</a>
<div class="unitBox" style="margin-left:360px;">
	<div class="pageHeader" style="border:1px #B8D0D6 solid">
	<div class="searchBar">
		<table class="searchContent">
			<tr>
				<td><h3>详细设置</h3>
				</td>

			</tr>
		</table>
	</div>
</div>	


<div class="pageContent" style="border:1px #B8D0D6 solid;"  layoutH="70">

<div class="pageFormContent" layoutH="128">

        <dl class="nowrap">
            <dt>编号：</dt>
            <dd><input id="Id" type="text" disabled="disabled" /></dd>
        </dl>
        <dl class="nowrap">
            <dt>标题：</dt>
            <dd><input id="ip_title" type="text"/></dd>
        </dl>
        <dl class="nowrap">
            <dt>上级编号：</dt>
            <dd><input id="ip_preid" type="text"/>&nbsp;请输入数字</dd>
        </dl>
        <dl class="nowrap">
            <dt>目录排序：</dt>
            <dd><input id="Sort" type="text" class="digits" />&nbsp;请输入数字</dd>
        </dl>
        <dl class="nowrap">
            <dt>参数：</dt>
            <dd><input id="ip_p1" type="text" /></dd>
        </dl>
        <dl >
         <dd><div class="button buttonHover">
                            <div class="buttonContent" onclick="jieshao();">
                                <button>
                                    分类介绍</button>
                            </div>
                        </div></dd>
           </dl>
</div>
<div class="formBar">
	    <ul>
			<li>
	        <div class="buttonActive"><div class="buttonContent"><button onclick="submitMenuItem();" type="button">提交</button></div></div>
            </li>
		</ul>
</div>
</div>
<script type="text/javascript">

    var kindid = 0;
    function submitMenuItem() {
        //alertMsg.confirm("请确认提交", {
        //   okCall: function () {
       
        $.get("/SystemManage/Basics/TypeTree/TypeTreeConfigInterface.aspx", { 
            Kind:"<%= Request["kind"] %>",
            opt: "update_ex", 
            Id: $("#Id", navTab.getCurrentPanel()).val(),
            
            Title: $("#ip_title", navTab.getCurrentPanel()).val(),
            Sort: $("#Sort", navTab.getCurrentPanel()).val(),
            Preid: $("#ip_preid", navTab.getCurrentPanel()).val(),
            Param1: $("#ip_p1", navTab.getCurrentPanel()).val(),
            temp: new Date().valueOf()
        },function () {
            alertMsg.correct("操作成功");
            _currentNode.Id = $("#Id", navTab.getCurrentPanel()).val();
            _currentNode.ShowOrder = $("#Sort", navTab.getCurrentPanel()).val();
            _currentNode.Preid = $("#ip_preid", navTab.getCurrentPanel()).val();
            _currentNode.Param1 = $("#ip_p1", navTab.getCurrentPanel()).val();
            _currentNode.Title = $("#ip_title", navTab.getCurrentPanel()).val();
        });
       var kindid=$("#Id", navTab.getCurrentPanel()).val();
        // }
        //});
    }

</script>
</div>
	
</div>